/**********************************************
 * 	SentenceChecker.java					  *
 *  Course: CS3343							  *
 *  Version: 1.1     Release 1				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package checker;

import file.FileIO;



public class SentenceChecker {

	
	private FileIO readFile;
	
	
	public SentenceChecker(){
		readFile = new FileIO();
	}

	public boolean isCompleteSentence(String fileName) {
		String sentence = readFile.getFileContents(fileName);
		if (startWithCapital(sentence) && endWithPunctuation(sentence)) {
			System.out.println("A simple sentense should end with '.' or '!' or '?'");
			return true;
		} else {
			System.out.println("This sentense is ended correctly");
			return false;
		}
	}

	public boolean startWithCapital(String sentence) {
		return Character.isUpperCase(sentence.charAt(0));
	}

	public boolean endWithPunctuation(String sentence) {
		char[] ending = { '.', '!', '?' };
		for (int i = 0; i < ending.length; i++) {
			if (sentence.charAt(sentence.length() - 1) == ending[i])
				return true;
		}
		return false;

	}

}